<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../include/base.jsp" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>欢迎使用CRM管理系统</title>
    <link rel="stylesheet" href="${basePath }/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="${basePath }/css/style.css" type="text/css" />
    <script type="text/javascript" src="${basePath }/js/jquery.min.js"></script>
    <script type="text/javascript" src="${basePath }/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="navbar">
        <div class="navbar-inner">
            <div class="container">
                <a href="${basePath }/message" class="brand">凯盛CRM管理系统</a>
                <div class="nav-collapse">
                    <ul class="nav">
                        <li><a href="${basePath }/message">最新动态</a></li>
						<li><a href="${basePath }/contacts/list">联系人</a></li>
						<li><a href="${basePath }/task/list">日程安排</a></li>
						<li  class="active"><a href="${basePath }/deal/list">业务机会</a></li>
                    </ul>
                    <ul class="nav pull-right">
                        <li><a href="#">${user.username }</a>
                        <li class="divider-vertical"></li>
                        <li><a href="${basePath }/user/info">账号设置</a></li>
                        <li><a href="${basePath }/user/loginout">退出</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div id="content" class="container">
        <div class="span9">
            <ul class="breadcrumb" style="vertical-align:top">
                <li ><a href="${basePath }/deal/list">业务机会</a></li>
				
            </ul>
            <div class="well">
                <div>
                    <table id="table">
                        <tr style="border-bottom:0px;">
                            <td style="width:130px">
                          		<div class="btn-group">
                          			<a id="dealState" href="#" class="btn  state">
	                          			<c:choose>
			                        		<c:when test="${deal.state == '创建' }">
			                        			追踪
			                        		</c:when>
			                        		<c:otherwise>
			                        			${deal.state }
			                        		</c:otherwise>
			                        	</c:choose>	
                          			</a>
                          			<a href="#" class="btn  dropdown-toggle state" data-toggle="dropdown"><span class="caret"></span></a>
                          			<ul class="dropdown-menu" style="min-width:72px;">
                          				<li id="success"><a href="${basePath }/deal/edit-dealState?state=1&id=${deal.id}">成功</a></li>
                          				<li id="fail"><a href="${basePath }/deal/edit-dealState?state=2&id=${deal.id}">失败</a></li>
                          				<li id="do"><a href="${basePath }/deal/edit-dealState?state=3&id=${deal.id}">追踪</a></li>
                          			</ul>
                          		</div>
                            </td>
                            <td style="width:734px">
                                <h3>${deal.title }</h3>
                                <c:if test="${deal.contacts.view != null }">
									联系人：<a href="${basePath }/contacts/detail?id=${deal.contacts.id}">${deal.contacts.name }</a><br/>
                                </c:if>
								负责人：${deal.user.username }<br/>
								类型：<span class="typelabel" style="background-color:${deal.dealType.color};">${deal.dealType.type}</span><br/>
								价值：${deal.money }<br/>
                            	内容：${deal.content }
                            </td>
                        </tr>
                    </table>
                </div>             
                <div id="myTabContent" class="tab-content">
                    <div id="note" class="tab-pane fade active in">
                        <div style="border-bottom:0px solid #ddd;padding-bottom:30px">
                            <h4>添加一个关于${deal.title }的记录</h4>
                            <form action="${basePath }/deal/add-dealNote" method="post" id="myform">
                            	<input type="hidden" name="id" value="${deal.id }">
                            	<input type="hidden" name="noteId" value="">
                           	 	<textarea style="width:650px" rows="4" name="dealNote.content"></textarea>
                            	<input  type="submit" class="btn pull-right" value="添加">
                            </form>
                        </div>
                        <div>
                        <c:forEach var="dealNote" items="${dealNoteList}" varStatus="status">
		                    <blockquote>
		                        <a href="#">${dealNote.user.username }</a>:${dealNote.content }<br/><br/>
		                        <small>
		                        	<a href="#re" data-toggle="collapse" data-target="#re${status.count }">回复</a>
		                        	<span class="pull-right">发布于 ${dealNote.createTime }</span>
		                        </small>
		                    </blockquote>
		                    <div id="re${status.count }" class="collapse">
                        		<form action="${basePath }/deal/add-dealNote" method="post">
                        			<input type="hidden" name="noteId" value="${dealNote.id }" />
                        			<input type="hidden" name="id" value="${deal.id }" />
                        			<div class="input-append">
                        				<input type="text" class="input-xxlarge" name="dealNote.content" /><button type="submit" class="btn">回复</button>
                        			</div>
                        		</form>
                        	</div>
	                    </c:forEach>
                        </div>
                    </div>                
                </div>
            </div>
        </div>
        <div class="span3">
        	<div class="btn-group" style="margin-bottom:20px;">
				<a href="${basePath }/deal/edit-deal?id=${deal.id}" class="btn">修改业务机会</a>	
				<a href="${basePath }/deal/dealType-new" class="btn">新建业务类型</a>
			</div>
           <div class="box well">
               <div class="head">联系人详情</div>
                   <ul style="list-style-type:none">
                    <li>姓名：${deal.contacts.name }</li>
                	<c:if test="${deal.contacts.telSet.size() != 0 }">
	                    <div>
	                    	电话：<br/>
	                    	<c:forEach items="${deal.contacts.telSet }" var="tel">
	                    		<li>
		                            ${tel.tel } (${tel.type })
		                        </li>
	                    	</c:forEach>
	                    </div>
                    </c:if>
                    <c:if test="${deal.contacts.mailSet.size() != 0 }">
	                    <div>
							邮箱：<br/>
	                        <c:forEach items="${deal.contacts.mailSet }" var="mail">
	                    		<li>
		                            ${mail.mail } (${mail.type })
		                        </li>
	                    	</c:forEach>
	                    </div>
                    </c:if>
                    <div>
                        <c:if test="${fn:length(deal.contacts.weibo) != 0 }">
	                        <li> 微博：${dealcontacts.weibo }</li>
	                    </c:if>
	                    <c:if test="${fn:length(deal.contacts.im) != 0 }">
	                        <li>QQ：${deal.contacts.im } </li>
                        </c:if>
                        <c:if test="${fn:length(deal.contacts.website) != 0 }">
	          	            <li> 主页：${deal.contacts.website }</li>
                        </c:if>
                        <c:if test="${fn:length(deal.contacts.address) != 0 }">
	                        <li>地址：${deal.contacts.address }</li>
                        </c:if>
                    </div>
                </ul>  
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function(){
			if($("#dealState").text().trim() == "追踪") {
				$(".state").addClass("btn-info");
				$("#success").show();
				$("#fail").show();
				$("#do").hide();				
			} else if($("#dealState").text().trim() == "失败") {
				$(".state").addClass("btn-danger");
				$("#success").show();
				$("#fail").hide();
				$("#do").show();
			} else {
				$(".state").addClass("btn-success");
				$("#success").hide();
				$("#fail").show();
				$("#do").show();
			}
		
        });
    </script>
</body>
</html>